﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Manager_EditSignTable2 : System.Web.UI.PageEx
{
    private DataSet ds = null;
    public static string strId = "0";
    private string strPageCode = "B0011";
    private string strLoginResult = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!DalEx.DbManagerEx.CheckLoginRight(UserType, UserId, strPageCode, ref strLoginResult))
        {
            FineUI.Alert.Show(strLoginResult, FineUI.MessageBoxIcon.Warning);
            Response.Redirect("Login.aspx");
        }
        if (!Page.IsPostBack)
        {
            DataBinds();
        }
    }
    private void DataBinds()
    {
        if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
        {
            strId = Request.QueryString["Id"].ToString();
        }
        int iUserId = 0;
        int.TryParse(strId, out iUserId);

        Model.BaoMing2 M_BaoMing = Dal.BaoMing2Dal.Select(iUserId);
        if (M_BaoMing != null)
        {
            hfSelectId.Value = M_BaoMing.Id.ToString();
            txtBabyName.Text = M_BaoMing.BabyName;
            txtParentName.Text = M_BaoMing.ParentName;
            ddlParentEducation.SelectedIndex = ddlParentEducation.Items.IndexOf(ddlParentEducation.Items.FindByValue(M_BaoMing.ParentEducation));
            txtMobile.Text = M_BaoMing.Mobile;
            txtWorkUnit.Text = M_BaoMing.WorkUnit;
            txtParentSkill.Text = M_BaoMing.ParentSkill;
            txtResources.Text = M_BaoMing.Resources;
        }

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strOrderSN = WebBase.Comm.GetOrderNo("ZC");
        string strBabyName = SqlHelper.String(txtBabyName.Text);
        string strParentName = SqlHelper.String(txtParentName.Text);
        string strParentEducation = SqlHelper.String(ddlParentEducation.SelectedValue);
        string strMobile = SqlHelper.String(txtMobile.Text);
        string strWorkUnit = SqlHelper.String(txtWorkUnit.Text);
        string strParentSkill = SqlHelper.String(txtParentSkill.Text);
        string strResources = SqlHelper.String(txtResources.Text);
        if (strBabyName.Length > 50)
        {
            MessageBox("幼儿姓名不能超过50个字！");
            return;
        }
        if (strParentName.Length > 100)
        {
            MessageBox("幼儿姓名不能超过100个字！");
            return;
        }
        if (strParentEducation == "")
        {
            MessageBox("请选择家长学历！");
            return;
        }
        if (strMobile.Length > 50)
        {
            MessageBox("联系电话不能超过50个字！");
            return;
        }
        if (strWorkUnit.Length > 200)
        {
            MessageBox("工作单位不能超过200个字！");
            return;
        }
        if (strParentSkill.Length > 250)
        {
            MessageBox("家长特长不能超过250个字！");
            return;
        }
        if (strResources.Length > 500)
        {
            MessageBox("可提供的资源不能超过500个字！");
            return;
        }
        int iUserId = 0;
        int.TryParse(hfSelectId.Value, out iUserId);
        Model.BaoMing2 M_BaoMing2 = Dal.BaoMing2Dal.Select(iUserId);
        M_BaoMing2.BabyName = strBabyName;
        M_BaoMing2.ParentName = strParentName;
        M_BaoMing2.ParentEducation = strParentEducation;
        M_BaoMing2.Mobile = strMobile;
        M_BaoMing2.WorkUnit = strWorkUnit;
        M_BaoMing2.ParentSkill = strParentSkill;
        M_BaoMing2.Resources = strResources;
        if (Dal.BaoMing2Dal.Update(M_BaoMing2) > 0)
        {
            FineUI.Alert.Show("修改成功！！！", FineUI.MessageBoxIcon.Information);
        }
        else
        {
            FineUI.Alert.Show("未能完成修改！", FineUI.MessageBoxIcon.Warning);
        }
    }
    private void setMeta(string title, string key, string des)
    {
        string strWebTitle = string.Empty, strWebKeywords = string.Empty, strWebDescription = string.Empty;
        Model.DbSystem dbSystem = Dal.DbSystemDal.Select(1);
        if (dbSystem != null)
        {
            strWebTitle = dbSystem.STitle;
            strWebKeywords = dbSystem.SKeywords;
            strWebDescription = dbSystem.SDescription;
        }
        HtmlMeta keywords = new HtmlMeta(); // keywords
        HtmlMeta description = new HtmlMeta(); // description
        keywords.Name = "keywords";
        keywords.Content = string.IsNullOrEmpty(key) ? strWebKeywords : key;

        this.Title = string.IsNullOrEmpty(title) ? strWebTitle : title;

        description.Name = "description";
        description.Content = string.IsNullOrEmpty(des) ? strWebDescription : des;

        Page.Header.Controls.Add(keywords);
        Page.Header.Controls.Add(description);
    }
}
